Добавил:
Chupapi_Munyanya
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
program lab_5_2_16_variant
integer, parameter :: NMAX = 100
integer:: rows, cols
real matrix(NMAX,NMAX), array(NMAX)
logical :: condition
WRITE (*,*) "Введите кол-во строк и столбцов: "
read (*,*) rows, cols
WRITE (*,*) "Введите матрицу: "
read (*,*) ((matrix(i,j),i=1,rows),j=1,cols)
condition = .true.
call check_sum_last_col(rows, cols, matrix, condition)
if(condition .eqv. .true.) THEN
call transform_matrix_into_array(rows, cols, matrix, array)
end if
end program lab_5_2_16_variant
SUBROUTINE check_sum_last_col(rows, cols, matrix, condition)
integer, parameter :: NMAX = 100
integer:: rows, cols
real :: matrix(NMAX,NMAX)
real :: value
logical :: condition
condition = .true.
value = 0
do i=1, rows
value = value + matrix(cols,i)
end do
if(value > 0) THEN
condition = .true.
ELSE
condition = .false.
end if
end SUBROUTINE check_sum_last_col
SUBROUTINE transform_matrix_into_array(rows, cols, matrix, array)
integer, parameter :: NMAX = 100
integer:: rows, cols
real :: matrix(NMAX,NMAX)
real :: array(NMAX)
real :: row_sum, average_value
do j=1, cols
row_sum = 0
do i=1, rows
row_sum = row_sum + matrix(i,j)
end do
average_value = row_sum/rows
array(j) = average_value
end do
write (*,*) (array(i),i=1,rows)
end SUBROUTINE transform_matrix_into_array
integer, parameter :: NMAX = 100
integer:: rows, cols
real matrix(NMAX,NMAX), array(NMAX)
logical :: condition
WRITE (*,*) "Введите кол-во строк и столбцов: "
read (*,*) rows, cols
WRITE (*,*) "Введите матрицу: "
read (*,*) ((matrix(i,j),i=1,rows),j=1,cols)
condition = .true.
call check_sum_last_col(rows, cols, matrix, condition)
if(condition .eqv. .true.) THEN
call transform_matrix_into_array(rows, cols, matrix, array)
end if
end program lab_5_2_16_variant
SUBROUTINE check_sum_last_col(rows, cols, matrix, condition)
integer, parameter :: NMAX = 100
integer:: rows, cols
real :: matrix(NMAX,NMAX)
real :: value
logical :: condition
condition = .true.
value = 0
do i=1, rows
value = value + matrix(cols,i)
end do
if(value > 0) THEN
condition = .true.
ELSE
condition = .false.
end if
end SUBROUTINE check_sum_last_col
SUBROUTINE transform_matrix_into_array(rows, cols, matrix, array)
integer, parameter :: NMAX = 100
integer:: rows, cols
real :: matrix(NMAX,NMAX)
real :: array(NMAX)
real :: row_sum, average_value
do j=1, cols
row_sum = 0
do i=1, rows
row_sum = row_sum + matrix(i,j)
end do
average_value = row_sum/rows
array(j) = average_value
end do
write (*,*) (array(i),i=1,rows)
end SUBROUTINE transform_matrix_into_array
Соседние файлы в папке Коды 5.2